#设计一个类
# class Student:
#     name=None        #记录姓名
#     gender=None       #记录性别
#     country=None     #记录国籍
#     jiguan=None       #记录籍贯
#     age=None          #记录年龄
# #创建一个对象
# stu_1=Student()
# #对象属性进行赋值
# stu_1.age=89
# stu_1.gender="male"
# stu_1.jiguan="sg"
# stu_1.country="sg"
# stu_1.name="林"
# #获取对象中记录的信息
# print(stu_1.name)
# print(stu_1.jiguan)
# print(stu_1.country)
# print(stu_1.gender)
# print(stu_1.age)
# #定义一个带有成员的方法的类
# class Student:
#     name=None        #记录姓名
#     gender=None       #记录性别
#
#     def say_hi(self):
#         print(f"大家好我是{self.name}")
#
#     def say_hi2(self,msg):
#         print(f"大家好，我是：{self.name},{msg}")
#
# stu=Student()
# stu.name="长春"
# stu.say_hi2("hai")
#
# stu2=Student()
# stu2.name="理工"
# stu2.say_hi2("xiao")
# #设计一个闹钟类
# class Clock:
#     id=None
#     price=None
#     def ring(self):
#         import winsound
 #         winsound.Beep(2000,5)
# #构建两个闹钟对象并让其工作
# clock1=Clock()
# clock1.id="72589"
# clock1.price="60"
# print(f"价格与名字为{clock1.price}，{clock1.id}")
# clock1.ring()
#
# clock2=Clock()
# clock2.id="89"
# clock2.price="80"
# print(f"价格与名字为{clock2.price}，{clock2.id}")
# clock2.ring()
import json
import random

#演示类的构造方法
#演示使用构造方法对成员变量进行赋值
#构造方法的名称__init__
# class Student:
#     # name=None         #不写也可以
#     # age=None
#     # tel=None
#
#     def __init__(self,name,age,tel):
#         self.name=name
#         self.age=age
#         self.tel=tel
#         print("Student类创建了一个类对象")
#
# stu=Student("周杰伦",31,41813640)
# print(stu.name,stu.age,stu.tel)

#练习
#
# class Student:
#     name=None
#     age=None
#     address=None
#     def __init__(self,name,age,address,list1):
#         self.name=name
#         self.age=age
#         self.address=address
#         self.list1=[
#             input(f"请输入学生姓名{self.name}"),
#             input(f"请输入学生姓名{self.age}"),
#             input(f"请输入学生姓名{self.address}")
#     ]
#         for x in list1:
#             i=1
#             print(f"学生{i}信息录入完成，信息为:"
#                   f"学生姓名{self.name}"
#                   f"年龄{self.age}"
#                   f"地址{self.address}"
#                   )
#             i+=1
# stu=Student()              #以上均为错误示例
# class Student:
#     def __init__(self, name, age, address):
#         self.name = name
#         self.age = age
#         self.address = address
#
#     def display_info(self):
#         print(f"【学生姓名：{self.name}，年龄：{self.age}，地址：{self.address}】")
#
#
# num_students = 10
# for i in range(1, num_students + 1):
#     print(f"当前录入第{i}位学生信息，总共需录入{num_students}位学生信息")
#     name = input("请输入学生姓名：")
#     age = input("请输入学生年龄：")
#     address = input("请输入学生地址：")
#     student = Student(name, age, address)
#     print(f"学生{i}信息录入完成，信息为：", end="")
#     student.display_info()
#
#
# class Student:
#     def __init__(self,name,age):
#         self.name=name
#         self.age=age
#
# #__str__魔术方法
#     def __str__(self):
#         return f"Student类对象，那么{self.name},age:{self.age}"


# stu=Student("周杰伦",31)
# print(stu)
# print(str(stu))

# #__lt__魔术方法
#     def __lt__(self,other):
#         return self.age<other.age
# # stu2=Student("林俊杰",90)
# # stu=Student("周杰伦",31)
# # print(stu<stu2)
#
# #__le__魔术方法
#     def __le__(self,other):
#         return self.age<=other.age
#
# # stu2=Student("林俊杰",90)
# # stu=Student("周杰伦",31)
# # print(stu<=stu2)
# #__eq__魔术方法
#     def __eq__(self,other):
#         return self.age==other.age
#
# stu2=Student("林俊杰",90)
# stu=Student("周杰伦",31)
# print(stu==stu2)
#
# #定义一个类，内含私有成员变量和私有成员方法
# class Phone:
#
#     __current_voltage=0.1
#
#     def __keep_single_core(self):
#         print("让CPU以单核模式运行")
#
#     def call_by_5g(self):
#         if self.__current_voltage>=1:
#             print("成功")
#         else:
#             self.__keep_single_core()
#             print("失败")
# phone=Phone()
# #phone.__keep_single_core()
# phone.call_by_5g()
# class Phone:                #定义一个类
#     __is_5g_enable=False     #定义私有成员变量
#
#     def __check_5g(self):   #定义私有成员方法
#         if self.__is_5g_enable==True:     #判断私有成员变量
#             print("5g开启")
#         else:
#             print("5g环比，使用4g网络")
#
#     def call_by_5g(self):             #定义公开成员方法
#         self.__check_5g()
#         print("正在通话中")
# phone=Phone()
# phone.call_by_5g()
# #演示继承
# class Phone:
#     imei=None
#     producer="hw"
#
#     def call_by_4g(self):
#         print("4g通话")
#
# class Phone2025(Phone):
#     face_1="8608"
#
#     def call_by_5g(self):
#         print("5g通话")
#
# phone=Phone2025()
# phone.call_by_5g()
# phone.call_by_4g()
# #演示多继承
# class Phone:
#     imei=None
#     producer="hw"
#
#     def call_by_4g(self):
#         print("4g通话")
# class NFCReader:
#     nnfc_type="第五代"
#     producer="hw"
#
#     def read_card(self):
#         print("读卡")
#     def write_card(self):
#         print("写卡")
#
# class RemoteControl:
#     rc_type="红外遥控"
#     def control(self):
#         print("红外遥控开启了")
#
# class MYPhone(Phone,NFCReader,RemoteControl):
#     pass#pass关键字，有补全功能,表示无内容，空的意思
# phone=MYPhone()
# phone.call_by_4g()
# phone.control()
# phone.read_card()
# phone.write_card()
#
# #定义子类，复写父类成员
# class Phone:
#     imei=None
#     producer="hw"
#
#     def call_by_4g(self):
#         print("4g通话")
# class Phone2025(Phone):
#
#     producer="xiaomi"
#
#     def call_by_5g(self):
#         print("5g通话")
#         print(f"{super().producer}")
#         print(f"{Phone.producer}")
#         super().call_by_4g()
#         Phone.call_by_4g(self)
# phone=Phone2025()
# phone.call_by_5g()
# s=phone.producer
# print(s)

#变量的数据类型注解

#基础数据类型的注解
# var_1:int=10
# var_2:float=1.1
# var_3:bool=False
# var_4:str="ghjhe"
#类对象类型注解
# class Student:
#     pass
# stu:Student=Student()
#
# #基础容器类型注解
# my_list:list[int]=[1,2,3,4]
# my_tuple:tuple[int,int,str,str]=(3,5,"f","o")
# my_dict:dict[str,str]={"wo":"hgs"}
# my_set:set[int]={3,65,78,9,5}
# # my_str:str[str]="uyktgaeh"
# #容器类型详细注解
# var_1=random.randint(1,10)    #type:int
# var_2=json.loads('{"name":"uyag"}')#type:dict[str,str]
# def func():
#     return 10
# var_3=func()      #type:int

#在注释中进行类型注解

#类型注解的限制

#对形参进行类型注解
# def add(x:int,y:int):
#     return x*y
# add(3,9)
# #对返回值进行类型注解
# def func(data:list) ->list:
#     return data
# print(func([1]))
# #演示Union联合类型注解
# from typing import *
# # my_list:list[Union[str,int]]=["skgh",32]
# def func(data:Union[int,str,bool]) ->Union[int,str]:
#     pass
# func("hash")
class Animal:
    def speak(self):
        pass
class Dog(Animal):
    def speak(self):
        print("汪汪汪")
class Cat(Animal):
    def speak(self):
        print("喵喵喵")
#演示抽象类
class Ac:
    def cool_wind(self):
        pass
    def hot_wind(self):
        pass
    def swing_l_r(self):
        pass

class Mide_Ac(Ac):
    def cool_wind(self):
        print("美的空调制冷")
    def hot_wind(self):
        print("美的空调制热")
    def swing_l_r(self):
        print("美的空调摇摆")

class GREE_Ac(Ac):
    def cool_wind(self):
        print("格力空调制冷")
    def hot_wind(self):
        print("格力空调制热")
    def swing_l_r(self):
        print("格力空调摇摆")
def make_cool(ac:Ac):
    ac.cool_wind()

midea_ac=Mide_Ac()
gree_ac=GREE_Ac()

make_cool(midea_ac)
make_cool(gree_ac)

